/**
 *
 * @ClassName: api.js
 * @Description: 请求API
 * @author acai
 * @date 2018年9月7日 下午1:20:55
 *
 */
import request from './request.js';
import helper from '../common/helper.js'
class api {
	constructor(options) {
		// this._baseUrl = window.config?.baseUrl || 'http://113.207.49.150:9876' // 测试
		this._baseUrl = window.config?.baseUrl || 'http://10.119.97.167:9876' // 生产
		// this._baseUrl = window.config?.baseUrl || 'http://127.0.0.1:9876' // 本地
		this._header = {
			// 'content-type': 'application/x-www-form-urlencoded',
			'content-type': 'application/json; charset=utf-8'
		}
		this._request = new request()
	}
	//封装通用方法
	//

	getAPI(url, key) {
		let heard = {
			Authorization: helper.token
		}
		return this._request.getRequest(this._baseUrl + url + key, {}, heard).then(res => res.data)
	}

	postAPI(url, data) {
		let heard = {
			Authorization: helper.token
		}
		return this._request.postRequest(this._baseUrl + url, data, heard).then(res => res.data)
	}

	deleteAPI(url, key) {
		let heard = {
			Authorization: helper.token
		}
		return this._request.deleteRequest(this._baseUrl + url + key, {}, heard).then(res => res.data)
	}

	putAPI(url, data) {
		let heard = {
			Authorization: helper.token
		}
		return this._request.putRequest(this._baseUrl + url, data, heard).then(res => res.data)
	}

}
export default api